package com.gdut.simple.model.impl;

import com.gdut.simple.common.RequestCallback;
import com.gdut.simple.data.entity.Feedback;
import com.gdut.simple.data.entity.Post;
import com.gdut.simple.data.entity.User;
import com.gdut.simple.model.IFeedbackModel;

import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.SaveListener;

public class FeedbackModelImpl implements IFeedbackModel {

    @Override
    public void feedback(User user, String content, String contact, final RequestCallback<String> callback) {
        Feedback feedback = new Feedback();
        feedback.setUser(user);
        feedback.setContent(content);
        feedback.setContact(contact);
        feedback.save(new SaveListener<String>() {
            @Override
            public void done(String s, BmobException e) {
                if (e == null) {
                    if (callback != null) {
                        callback.onSuccess(s);
                    }
                } else {
                    if (callback != null) {
                        callback.onFailure(e.getMessage());
                    }
                }
            }
        });
    }
}
